----------------------------------------------------------------------------
-- Log module.
-- @module Log
-- @author v.v.balashoff
-- @license CC BY-NC-SA 4.0
----------------------------------------------------------------------------

local log = {}

log.level = 'all'
--log.format = (("%02d:%02d:%02d"):format(time.hour,time.min, time.sec))

function log:debug(text)
    if (self.level == 'debug') or (self.level == 'all') then
        --print ('\27[1;33m'..self.format..' DEBUG: '..text..'\27[0m')
        print ('\27[1;90m[DEBUG] '..text..'\27[0m')
    end
end

function log:info(text)
    if (self.level == 'info') or (self.level == 'all') then
        print('\27[32m[INFO ] '..text..'\27[0m')
    end
end

function log:warning(text)
    if (self.level == 'warning') or (self.level == 'all') then
        print('\27[35m[WARNG] '..text..'\27[0m')
    end
end

function log:error(text)
    if (self.level == 'error') or (self.level == 'all') then
        print('\27[31m[ERROR] '..text..'\27[0m')
    end
end

function log:critical(text)
    if (self.level == 'critical') or (self.level == 'all') then
        print('\27[31m[CRITI] '..text..'\27[0m')
    end
end

return log
